package opencm;

import java.util.ArrayList;
import java.util.List;


public final class RepositorioPlanoSaude implements Repositorio<PlanoSaude> {

	private final List<PlanoSaude> planosSaude = new ArrayList<PlanoSaude>();
	
	@Override
	public void adicionarItens(List<PlanoSaude> itens) {
		this.planosSaude.addAll(itens);
		if (planosSaude.isEmpty())
			planosSaude.add(PlanoSaude.criarPlanoSaudeInicial());
	}

	@Override
	public List<PlanoSaude> getItens() {
		return new ArrayList<PlanoSaude>(this.planosSaude);
	}
	
	public void adicionar(PlanoSaude planoSaude) {
		this.planosSaude.add(planoSaude);		
	}
	
	public List<PlanoSaude> pesquisar() {
		List<PlanoSaude> validos = new ArrayList<PlanoSaude>();
		for (PlanoSaude ps : this.planosSaude) {
			if (ps.isValido()) {
				validos.add(ps);
			}
		}
		return validos;
	}

	public int contar() {
		return this.planosSaude.size();
	}
	
}
